version 13
#delimit;
clear all;
set more off;
capture log close;


global strformat "%8.3f";

capture program drop sig_p;
program sig_p;
   args obj_var point_est_var point_sd_var p_val row_id_var row_num;
   local point_est `point_est_var';
   local point_sd `point_sd_var';
   if `p_val' > 0.1 {;
      replace `obj_var' = string(`point_est', "$strformat") if `row_id_var' == `row_num';
      };
   if `p_val' > 0.05 & `p_val' <= 0.1  {;
      replace `obj_var' = string(`point_est', "$strformat")+"*" if `row_id_var' == `row_num';
      };
   if `p_val' > 0.01 & `p_val' <= 0.05  {;
      replace `obj_var' = string(`point_est', "$strformat")+"**" if `row_id_var' == `row_num';
      };
   if `p_val' <= 0.01 {;
      replace `obj_var' = string(`point_est', "$strformat")+"***" if `row_id_var' == `row_num';
      };
   replace `obj_var' = "<" + string(`point_sd', "$strformat") + ">" + " " if `row_id_var' == `row_num' + 1;
   end;


*enter directory name here;

use "$dir/ReStat_children.dta", clear;




graph twoway
	(lpoly fu_child_enrolled min_school_dist_sef if pooled_treatment == 0 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_sef < 1 [aw=hh_weight], bw(0.15))
	(lpoly fu_child_enrolled min_school_dist_sef if pooled_treatment == 1 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_sef < 1 [aw=hh_weight], bw(0.15)),
	legend(order ( 1 "Control" 2 "Treatment"))
	scheme(s2mono)
	bgcolor(white) graphregion(color(white))
	xtitle("Distance Proposed Program School (kms)")
	ytitle("Probability of Enrollment");
graph export  "$dir/Figure_1a_distance_program_enrollment.pdf", replace; 

graph twoway
	(lpoly total_score_pct min_school_dist_sef if pooled_treatment == 0 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_sef < 1 [aw=hh_weight], bw(0.15))
	(lpoly total_score_pct min_school_dist_sef if pooled_treatment == 1 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_sef < 1 [aw=hh_weight], bw(0.15)),
	legend(order ( 1 "Control" 2 "Treatment"))
	scheme(s2mono)
	bgcolor(white) graphregion(color(white))
	xtitle("Distance Proposed Program School (kms)")
	ytitle("Test Score");
graph export  "$dir/Figure_1b_distance_program_test_scores.pdf", replace;




graph twoway
	(lpoly fu_child_enrolled min_school_dist_any if pooled_treatment == 0 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_any < 1.5 [aw=hh_weight], bw(0.15))
	(lpoly fu_child_enrolled min_school_dist_any if pooled_treatment == 1 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_any < 1 [aw=hh_weight], bw(0.15)),
	legend(order ( 1 "Control" 2 "Treatment"))
	scheme(s2mono)
	bgcolor(white) graphregion(color(white))
	xtitle("Distance Nearest School (kms)")
	ytitle("Probability of Enrollment");
graph export  "$dir/Figure_2a_distance_enrollment.pdf", replace;


graph twoway
	(lpoly total_score_pct min_school_dist_any if pooled_treatment == 0 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_any < 1.5 [aw=hh_weight], bw(0.15))
	(lpoly total_score_pct min_school_dist_any if pooled_treatment == 1 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_any < 1 [aw=hh_weight], bw(0.15)),
	legend(order ( 1 "Control" 2 "Treatment"))
	scheme(s2mono)
	bgcolor(white) graphregion(color(white))
	xtitle("Distance Nearest School (kms)")
	ytitle("Test Score");
graph export  "$dir/Figure_2b_distance_test_scores.pdf", replace;
  
  
  
  
 
graph twoway
	(lpoly fu_child_enrolled min_school_dist_sef if pooled_treatment == 0 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_sef < 1 & fu_female == 0 [aw=hh_weight], bw(0.15))
	(lpoly fu_child_enrolled min_school_dist_sef if pooled_treatment == 0 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_sef < 1 & fu_female == 1 [aw=hh_weight], bw(0.15))
	(lpoly fu_child_enrolled min_school_dist_sef if pooled_treatment == 1 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_sef < 1 & fu_female == 0 [aw=hh_weight], bw(0.15))
	(lpoly fu_child_enrolled min_school_dist_sef if pooled_treatment == 1 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_sef < 1 & fu_female == 1 [aw=hh_weight], bw(0.15)),
	legend(order ( 1 "Control (Male)" 2 "Control (Female)" 3 "Treatment (Male)" 4 "Treatment (Female)"))
	scheme(s2mono)
	bgcolor(white) graphregion(color(white))
	xtitle("Distance Proposed Program School (kms)")
	ytitle("Probability of Enrollment");
graph export  "$dir/Figure_A1_distance_program_enrollment_gender.pdf", replace;

graph twoway
	(lpoly total_score_pct min_school_dist_sef if pooled_treatment == 0 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_sef < 1 & fu_female == 0 [aw=hh_weight], bw(0.15))
	(lpoly total_score_pct min_school_dist_sef if pooled_treatment == 0 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_sef < 1 & fu_female == 1 [aw=hh_weight], bw(0.15))
	(lpoly total_score_pct min_school_dist_sef if pooled_treatment == 1 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_sef < 1 & fu_female == 0 [aw=hh_weight], bw(0.15))
	(lpoly total_score_pct min_school_dist_sef if pooled_treatment == 1 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_sef < 1 & fu_female == 1 [aw=hh_weight], bw(0.15)),
	legend(order ( 1 "Control (Male)" 2 "Control (Female)" 3 "Treatment (Male)" 4 "Treatment (Female)"))
	scheme(s2mono)
	bgcolor(white) graphregion(color(white))
	xtitle("Distance Proposed Program School (kms)")
	ytitle("Test Score");
graph export  "$dir/Figure_A2_distance_program_test_score_gender.pdf", replace;





graph twoway
	(lpoly fu_child_enrolled min_school_dist_any if pooled_treatment == 0 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_any < 1.5 & fu_female == 0 [aw=hh_weight], bw(0.15))
	(lpoly fu_child_enrolled min_school_dist_any if pooled_treatment == 0 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_any < 1.5 & fu_female == 1 [aw=hh_weight], bw(0.15))
	(lpoly fu_child_enrolled min_school_dist_any if pooled_treatment == 1 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_any < 1.5 & fu_female == 0 [aw=hh_weight], bw(0.15))
	(lpoly fu_child_enrolled min_school_dist_any if pooled_treatment == 1 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_any < 1.5 & fu_female == 1 [aw=hh_weight], bw(0.15)),
	legend(order ( 1 "Control (Male)" 2 "Control (Female)" 3 "Treatment (Male)" 4 "Treatment (Female)"))
	scheme(s2mono)
	bgcolor(white) graphregion(color(white))
	xtitle("Distance Nearest School (kms)")
	ytitle("Probability of Enrollment");
graph export  "$dir/Figure_A1_distance_enrollment_gender.pdf", replace;

graph twoway
	(lpoly total_score_pct min_school_dist_any if pooled_treatment == 0 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_any < 1.5 & fu_female == 0 [aw=hh_weight], bw(0.15))
	(lpoly total_score_pct min_school_dist_any if pooled_treatment == 0 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_any < 1.5 & fu_female == 1 [aw=hh_weight], bw(0.15))
	(lpoly total_score_pct min_school_dist_any if pooled_treatment == 1 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_any < 1.5 & fu_female == 0 [aw=hh_weight], bw(0.15))
	(lpoly total_score_pct min_school_dist_any if pooled_treatment == 1 & fu_child_level == 1 & fu_young_child == 1 &
		min_school_dist_any < 1.5 & fu_female == 1 [aw=hh_weight], bw(0.15)),
	legend(order ( 1 "Control (Male)" 2 "Control (Female)" 3 "Treatment (Male)" 4 "Treatment (Female)"))
	scheme(s2mono)
	bgcolor(white) graphregion(color(white))
	xtitle("Distance Nearest School (kms)")
	ytitle("Test Score");
graph export  "$dir/Figure_A2_distance_test_score_gender.pdf", replace;
  
  
twoway 
	(hist total_score_pct if pooled_treatment == 0 & fu_child_level == 1 & fu_young_child == 1, width(.025) frac lcolor(gs13) fcolor(gs13)) 
	(hist total_score_pct if pooled_treatment == 1 & fu_child_level == 1 & fu_young_child == 1, width(.025) frac fcolor(none) lcolor(black)), 
	legend(order (1 "Control Villages" 2 "Treatment Villages"))
	scheme(s2mono)
	bgcolor(white) graphregion(color(white))
	xtitle("Percent Correct Answers"); 
graph export  "$dir/Figure_B1_test_score_distribution.pdf", replace;
 
